using System;
using System.Collections;
using System.Collections.Generic;
using SevenPieceGame;
using DG.Tweening;
using GTA;
using MotionFramework.Event;
using UnityEngine;
using UnityEngine.UI;

public class UIGuide : MonoBehaviour
{
    private EventGroup EventGrouper = new EventGroup();

    private GameObject m_Guide_1002;
    private Button m_BtnGuide_1002_OK;

    private GameObject m_Guide_1003;
    private Button m_BtnGuide_1003_OK;
    
    private GameObject m_Hand;
    
    void Awake()
    {
        OnCreate();
    }

    private void OnCreate()
    {
        m_Guide_1002 = this.transform.Find("Root/Point/MiddleMask/Guide_1002").gameObject;
        m_BtnGuide_1002_OK = this.transform.Find("Root/Point/MiddleMask/Guide_1002/Group/Button").GetComponent<Button>();

        m_BtnGuide_1002_OK.onClick.AddListener(OnClickGuide_1002_OK);
        
        m_Guide_1003 = this.transform.Find("Root/Point/MiddleMask/Guide_1003").gameObject;
        m_BtnGuide_1003_OK = this.transform.Find("Root/Point/MiddleMask/Guide_1003/Group/Background").GetComponent<Button>();

        m_BtnGuide_1003_OK.onClick.AddListener(OnClickGuide_1003_OK);
    
        m_Hand = this.transform.Find("Root/Point/MiddleMask/Hand").gameObject;
    }

    public void ShowGuide()
    {
        int _guideId = PlayerPrefsManager.GetInt(PlayerPrefsManager.PLAYER_GUIDE_SHOW_ID, 1002);
        switch (_guideId)
        {
            case 1002:
            {
                _guideId++;
                PlayerPrefsManager.SetInt(PlayerPrefsManager.PLAYER_GUIDE_SHOW_ID, _guideId);
                ShowGuide1002();
                break;
            }
            case 1003:
            {
                _guideId++;
                PlayerPrefsManager.SetInt(PlayerPrefsManager.PLAYER_GUIDE_SHOW_ID, _guideId);
                ShowGuide1003();
                break;
            }
            default:
            {
                HideAll();
                MainManager.Instance.HideUIGuide();
                break;
            }
        }
    }

    private void ShowGuide1002()
    {
        m_Guide_1002.SetActive(true);
    }

    private void ShowGuide1003()
    {
        m_Guide_1003.SetActive(true);
        m_Hand.SetActive(true);
        m_Hand.transform.DOScale(Vector3.one * 1.1f,0.5f);
    }

    private void HideAll()
    {
        m_Guide_1002.SetActive(false);
        m_Guide_1003.SetActive(false);
        m_Hand.SetActive(false);
    }
    
    private void OnClickGuide_1002_OK()
    {
        AdjustWrapper.Instance.LogEvent("uiv2q9", null);
        MainManager.Instance.AddDoller(1000);
        HideAll();
        ShowGuide();
        //MainManager.Instance.HideUIGuide();
    }

    private void OnClickGuide_1003_OK()
    {
        HideAll();
        MainManager.Instance.HideUIGuide();
        MainManager.Instance.ShowUIShop();
    }
}
